<template>
    <div class="group-item">
        <div class="left">
            <div class="image">
                <div v-for="(member, index) in item.member" :key="index">
                    <van-image
                        v-if="index < 9"
                        width="18"
                        height="18"
                        :src="member.avatar_url ? global.MINIO_FILE_DOMAIN + member.avatar_url : 'src/assets/images/default_avatar.png'"
                        fit="contain"
                    />
                </div>
            </div>
            <div class="title">{{item.name}}</div>
            <div class="value">({{ item.member.length }})</div>
        </div>
        <div class="right" v-if="is_arrows"><i class="iconfont icon-youjiantou"></i></div>
    </div>
</template>

<script lang="ts" setup>
import type { GroupChat } from '@/types/groupChat'
import { inject } from 'vue'

// 全局属性
const global: any = inject('global')

defineProps<{
    item: GroupChat,
    is_arrows?: boolean
}>()
</script>

<style scoped lang="scss">
.group-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background-color: #fff;
    border-bottom: 1px solid #ececec;
    padding: 15px 10px;
    .left {
        flex: 1;
        display: flex;
        align-items: center;
        .image {
            width: 60px;
            height: 60px;
            border-radius: 5px;
            overflow: hidden;
            margin-right: 10px;
            border: 1px solid #ececec;
            display: flex;
            flex-wrap: wrap;
            justify-content: center;
            align-items: center;
        }
        .title {
            font-size: 16px;
            color: #000;
        }
        .value {
            padding-left: 2px;
            color: #9b9999;
            font-size: 14px;
            justify-content: flex-end;
            line-height: 22px;
        }
    }
    .right {
        width: 20px;
        .iconfont {
            font-size: 14px;
            color: #9b9999;
        }
    }
}
</style>